const mongoose = require("mongoose")
const { Schema, model } = mongoose

const commentSchema = new Schema({
    __v: {
        type: Number,
        select: false
    },
    // 评论内容
    content: {
        type: String,
        required: true
    },
    // 评论人
    commentator: {
        type: Schema.Types.ObjectId,
        ref: "User",
        required: true
    },
    questionId: {
        type: String,
        required: true
    },
    answerId: {
        type: String,
        required: true
    },
    rootCommentId: {
        type: String
    },
    replyTo: {
        type: Schema.Types.ObjectId,
        ref: "User"
    }
}, { timestamps: true })

module.exports = model("Comment", commentSchema)